package Stages

import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.TextureRegion
import com.badlogic.gdx.scenes.scene2d.InputEvent
import com.badlogic.gdx.scenes.scene2d.InputListener
import com.badlogic.gdx.scenes.scene2d.Stage
import com.badlogic.gdx.scenes.scene2d.ui.Image
import floatHeight
import floatWidth
import image
import setOnTouchListener
import stageFlag

/**
 * 商店舞台
 */
class StoreStage : Stage()
{
    val texture by lazy { Texture(Gdx.files.internal("shop.png")) }
    val bgRegion by lazy { TextureRegion(texture, 0, 83, 514, 374) }
    val heartRegion by lazy { TextureRegion(texture, 0, 0, 97, 83) }
    val glodRegion by lazy { TextureRegion(texture, 110, 0, 97, 83) }
    val moguRegion by lazy { TextureRegion(texture, 211, 0, 97, 83) }


    val bgImage by lazy { Image(bgRegion) }
    val heartImage by lazy { Image(heartRegion) }
    val glodImage by lazy { Image(glodRegion) }
    val moguImage by lazy { Image(moguRegion) }
    val exitImage by lazy { image("exit.png") }

    init
    {
        bgImage.setSize(Gdx.graphics.floatWidth, Gdx.graphics.floatHeight)
        moguImage.translate(63f, 194f)
        glodImage.translate(193f, 189f)
        heartImage.translate(325f, 193f)
        exitImage.translate(425f, 266f)

        exitImage.setOnTouchListener { image, touchState ->
            if (touchState == TouchState.touchUp)
            {
                stageFlag = MainPage.STAGE_FLAG.GAME
            }
        }

        addActor(bgImage)
        addActor(glodImage)
        addActor(heartImage)
        addActor(moguImage)
        addActor(exitImage)
    }
}